package edu.hawaii.myisern.commandline;

import static org.junit.Assert.assertEquals;
import java.io.File;
import org.junit.Test;

/**
 * Demonstrates that the MyIsernTableCreator class is working. 
 * 
 * @author Phuoc Le
 * @author Ka Yee Leung
 * @author Jared Sunouchi
 */
public class TestMyIsernTableCreator {
  
  private String userDirectory = "user.dir";
  private File validCollaborationFile = new File(System.getProperty(userDirectory)
      + "/xml/tests/test.collaborations.example.xml");
  private File validOrganizationFile = new File(System.getProperty(userDirectory)
      + "/xml/tests/test.organizations.example.xml");
  private File validResearcherFile = new File(System.getProperty(userDirectory)
      + "/xml/tests/test.researchers.example.xml");
  
  /**
   * Tests the methods of MyIsernTableCreator. 
   * @throws Exception If problems occur.
   */
  @Test public void testTableCreator() throws Exception {
    MyIsernXmlLoader loader = new MyIsernXmlLoader(validCollaborationFile, validOrganizationFile, 
        validResearcherFile);
    MyIsernTableCreator creator = new MyIsernTableCreator(loader);
    
    // verifies the methods to obtain size of collaborations, organizations or researchers
    assertEquals("Check collaborations table size", 1, 
        creator.createCollaborationTable().getRowCount());
    assertEquals("Check organizations table size", 2, 
        creator.createOrganizationTable().getRowCount());
    assertEquals("Check researchers table size", 3, 
        creator.createResearcherTable().getRowCount());
  }
}
